str[y:] returns a substring starting at index y
def for_loop5(str, x, y):
    result = 0
    for i in str[y:]:
        if i == x:
            result += 1
    return result| Function Call | Return Value | |||
|---|---|---|---|---|
| for_loop5('athenian', 'e', 2) | → | |||
| for_loop5('apples', 'p', 1) | → | |||
| for_loop5('hello', 'a', 3) | → | |||
| for_loop5('aa', 'a', 1) | → | |||
Experiment with this code on Gitpod.io